// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 

package com.yoyo.series.utilites;

import android.os.Environment;
import java.io.File;

import com.yoyo.series.entities.ImageEntity;

public class FileUtilities {

    public FileUtilities() {
    }

    public static boolean checkIsDownload(ImageEntity imageentity) {
        boolean flag;
        if ((new File(getFavImageFile(imageentity))).exists())
            flag = true;
        else
            flag = false;
        return flag;
    }

    public static void checkRoot() {
        if (!isDirExist(ROOTPATH)) {
            String as[] = new String[1];
            as[0] = ROOTPATH;
            createDir(as);
        }
    }

    public static void createDir(String as[]) {
        for (int i = 0; i < as.length; i++) {
            File file = new File(as[i]);
            if (!file.exists() && !file.isDirectory())
                file.mkdirs();
        }

    }

    public static void deleteFile(String s) {
        File file = new File(s);
        if (file.exists())
            if (file.isDirectory()) {
                String as[] = file.list();
                for (int i = 0; i < as.length; i++)
                    deleteFile((new StringBuilder()).append(s).append(File.separator).append(as[i])
                            .toString());

                file.delete();
            } else {
                file.delete();
            }
    }

    public static String getBaseFilePath() {
        return ROOTPATH;
    }

    public static String getDBFilePath() {
        checkRoot();
        return (new StringBuilder()).append(ROOTPATH).append(File.separator).append("database.dat")
                .toString();
    }

    public static String getFavImageFile(ImageEntity imageentity) {
        return (new StringBuilder()).append(getFavImageFolder()).append(File.separator)
                .append(imageentity.groupId).append("").append(imageentity.categroyId).append("")
                .append(imageentity.imageId).append(".jpg").toString();
    }

    public static String getFavImageFolder() {
        String as[] = new String[1];
        as[0] = (new StringBuilder()).append(ROOTPATH).append(File.separator).append("fav").toString();
        createDir(as);
        return (new StringBuilder()).append(ROOTPATH).append(File.separator).append("fav").toString();
    }

    public static String getImageFolder() {
        String as[] = new String[1];
        as[0] = (new StringBuilder()).append(ROOTPATH).append(File.separator).append("image").toString();
        createDir(as);
        return (new StringBuilder()).append(ROOTPATH).append(File.separator).append("image").toString();
    }

    public static void initFolders() {
        String as[] = new String[1];
        as[0] = ROOTPATH;
        createDir(as);
    }

    public static boolean isDirExist(String s) {
        File file = new File(s);
        boolean flag;
        if (file.exists() && file.isDirectory())
            flag = true;
        else
            flag = false;
        return flag;
    }

    public static boolean isFileExist(String s) {
        return (new File(s)).exists();
    }

    public static final String DB_NAME = "database.dat";
    public static final String PROJECT_NAME = "KanNiMei";
    public static final String ROOTPATH;

    static {
        ROOTPATH = (new StringBuilder()).append(Environment.getExternalStorageDirectory().getAbsolutePath())
                .append(File.separator).append("KanNiMei").toString();
    }
}
